
const mongoUtil = require("../utils/mongo_util")
//修改热门电视剧信息
function patchData(TvObj,collectionName, callback) {
    if (TvObj.title) {
        const whereStr = {
            'doubanId': TvObj.doubanId,
        }
        const updateStr = {
            $set: {
                doubanId: TvObj.doubanId,
                title: TvObj.title,
                rate: TvObj.rate,
                poster: TvObj.poster
            }
        };
        mongoUtil.getCollection(collectionName).then(collection => {
            collection.updateOne(whereStr, updateStr, function (err, res) {
                callback(err, res)
            });
        })
    }else{
        const whereStr = {
            'doubanId': TvObj.doubanId,
        }
        const updateStr = {
            $set: {
                poster: TvObj.poster
            }
        };
        mongoUtil.getCollection(collectionName).then(collection => {
            collection.updateOne(whereStr, updateStr, function (err, res) {
                callback(err, res)
            });
        })
    }

}
module.exports={
    patchData
}